<template>
  <div id="container">
    <section id="main">	
      <div class="schedule">
        <h1 class="headdateLine">
            <button type="button" class="headdateLine-btn" @click="addMonth" ><i class="mint-toast-icon mintui mintui-back"></i></button>
            {{billdatestr}}
            <button type="button" class="headdateLine-btn" @click="addMonth" ><i class="mint-toast-icon mintui mintui-back goit"></i></button>
        </h1>
        <div class="tip" v-show="!billList.length">
            請求データありません
        </div>
        <div class="user-info">
            <p class="name">管理员 村上太郎の許可</p>
            <p class="btn"><span class="left">返回123预定</span><span class="right">返回311列表</span></p>
        </div>
        <div class="body">
            <div class="left"></div>
            <div class="right"></div>
        </div>
      </div>
    </section>
  </div>
</template>

<script>
import moment from 'moment'
export default {
	data() {
		return {
            customerName: '',
			filter: {
                billDate:''
            },
            billdate: moment(new Date()).format('YYYY-MM-DD'),
            billdatestr: '',
            billList:[]
		}
    },
    
	created() {
        this.customerName = this.Session.get('customerName');
        this.filter.billDate = moment(new Date()).format('YYYYMMFD')
        // this.getInitData();
        this.billdatestr = moment(this.billdate).format('YYYY年MM月DD');
    },

    methods: {
        getInitData() {
            this.Api.get('bill', this.filter).then(res => {
                if (res.data.data) {
                    this.billList = res.data.data;
                }
            }).catch(err => {
            });
        },

        addMonth() {
            let dateArr = this.billdate.split('-');
            var year = dateArr[0];
            var month = dateArr[1];
            let day = dateArr[2];
            month =  parseInt(month) + 1;
            if (month > 12) {
                year = parseInt(year) + 1;
                month = 1;
            }
            this.billdate = moment(new Date(year, month, 0)).format('YYYY-MM-DD');
            this.billdatestr = moment(this.billdate).format('YYYY年MM月DD');
            this.filter.billDate = moment(new Date(this.billdate)).format('YYYYMMDD')
            // this.getInitData();
        },
        subtractMonth() {
            let dateArr = this.billdate.split('-');
            var year = dateArr[0];
            var month = dateArr[1];
            let day = dateArr[2];
            month =  parseInt(month) -1;
            if (month < 1) {
                year = parseInt(year) - 1;
                month = 12;
            }
            this.billdate = moment(new Date(year, month, 0)).format('YYYY-MM-DD');
            this.billdatestr = moment(this.billdate).format('YYYY年MM月DD');
            this.filter.billDate = moment(new Date(this.billdate)).format('YYYYMMDD')
            // this.getInitData();
        }
    }
    
}
</script>
